package io.lvdaxian.mybatis07.mapping;


import io.lvdaxian.mybatis07.session.Configuration;

import java.util.Map;

public class MappedStatement {
  
  // mapper id
  private String id;
  // 配置文件
  private Configuration configuration;
  private SqlCommandType sqlCommandType;
  private BoundSql boundSql;
  private Map<Integer, String> parameter;
  
  public MappedStatement() {
  }
  
  // 建造者 模式
  public static class Builder {
    
    private final MappedStatement mappedStatement = new MappedStatement();
    
    public Builder(Configuration configuration, String id, SqlCommandType sqlCommandType, BoundSql boundSql) {
      mappedStatement.configuration = configuration;
      mappedStatement.id = id;
      mappedStatement.sqlCommandType = sqlCommandType;
      mappedStatement.boundSql = boundSql;
    }
    
    public MappedStatement build() {
      assert mappedStatement.configuration != null;
      assert mappedStatement.id != null;
      return mappedStatement;
    }
  }
  
  public Configuration getConfiguration() {
    return configuration;
  }
  
  public void setConfiguration(Configuration configuration) {
    this.configuration = configuration;
  }
  
  public String getId() {
    return id;
  }
  
  public SqlCommandType getSqlCommandType() {
    return sqlCommandType;
  }
  
  public Map<Integer, String> getParameter() {
    return parameter;
  }
  
  public BoundSql getBoundSql() {
    return boundSql;
  }
}
